Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 3 - Values / Value Class Definitions


Real

Values that belong to the class Real are positive or negative numbers that can include a decimal fraction, such as 3.14159 and 1.0.

LITERAL EXPRESSIONS
10.2579432
1.0
1. 
As shown in the third example, a decimal point indicates a real number, even if there is no fractional part.

Real numbers can also be written using exponential notation. A letter e is preceded by a real number (without intervening spaces) and followed by an integer exponent (also without intervening spaces). The exponent can be either positive or negative. To obtain the value, the real number is multiplied by 10
to the power indicated by the exponent, as in these examples:

1.0e5 --equivalent to 1.0 * 10^5, or 100000
1.0e+5 --same as 1.0e5
1.0e-5 --equivalent to 1.0 * 10^-5, or .00001
PROPERTY
Class
The class identifier for the object. This property is read-only, and its value is always real.
ELEMENTS
None

OPERATORS
The ÷ and / operators always return Real values as their results. The +, -,
*, Mod, and ^ operators return Real values if either of their operands is a
Real value.

The operators that can have Real values as operands are +, -, *, ÷ (or /), Div, Mod, ^, =, , >, , <, and .

COERCIONS SUPPORTED
AppleScript supports coercion of a Real value to a single-item list or a
string. AppleScript supports coercion of a Real value to an Integer value
only if the Real value has no fractional part.

AppleScript also supports coercion of a Real value using the synonym Number, but the class of the resulting value remains unchanged:

set x to 1.5 as number
class of x --result: real
NOTES
Real numbers that are greater than or equal to 10,000.0 or less than or equal to 0.0001 are converted to exponential notation when scripts are compiled. The largest value that can be evaluated (positive or negative) is 1.79769e+308.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996